Skip to content

fix: remove secrets from evault core - #413

Merged
coodos merged 1 commit into
mainfrom
hotfix/remove-secrets-dep
Nov 12, 2025
Merged

coodos merged 1 commit into
mainfrom
hotfix/remove-secrets-dep

Conversation

@sosweetham

@sosweetham sosweetham commented Nov 12, 2025 •

Copy link
Copy Markdown
Member

Description of change

removes secrets dependency in evault core

Issue Number

n/a

Type of change

  • Fix (a change which fixes an issue)

How the change has been tested

ci checks

Change checklist

  • I have ensured that the CI Checks pass locally
  • I have removed any unnecessary logic
  • My code is well documented
  • I have signed my commits
  • My code follows the pattern of the application
  • I have self reviewed my code

Summary by CodeRabbit

  • Refactor
    • Simplified the initialization process for W3ID by removing internal secret management layers and streamlining the runtime flow, while maintaining the existing public API interface.

@sosweetham
sosweetham requested a review from coodos as a code owner November 12, 2025 15:54
@coderabbitai

coderabbitai Bot commented Nov 12, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

The W3ID initialization logic is refactored to remove cryptographic key management and signing operations. Secret storage, nacl-based key handling, seed persistence, and signer creation are eliminated. The public API surface remains unchanged, but internal construction paths are simplified to directly build the W3IDBuilder instance.

Changes

Cohort / File(s) Summary
W3ID Cryptographic Simplification
infrastructure/evault-core/src/core/w3id/w3id.ts
Removes SecretsStore dependency, seed/key management, and createSigner logic. Switches imports to type-only usage. Eliminates private static secretsStore field. Simplifies runtime initialization to use only withId, withRepository, and withGlobal builders without signer or nextKeyHash.

Sequence Diagram

sequenceDiagram
    participant Caller
    participant W3ID
    participant Builder
    
    rect rgb(240, 248, 255)
    note right of Caller: Previous Flow (Removed)
    Caller->>W3ID: W3ID.get(id, driver, password)
    W3ID->>W3ID: Load/Create Seed
    W3ID->>W3ID: Create Signer from Seed
    W3ID->>W3ID: Store Seed (persistence)
    end
    
    rect rgb(245, 255, 240)
    note right of Caller: New Simplified Flow
    Caller->>W3ID: W3ID.get(id, driver, password)
    W3ID->>Builder: withId(id)
    Builder->>Builder: withRepository(driver)
    Builder->>Builder: withGlobal()
    Builder-->>W3ID: Build Instance
    W3ID-->>Caller: Return W3ID
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Security implications: Removal of cryptographic key handling and signing logic requires careful verification that this is intentional and that no security guarantees are being lost.
  • Initialization path verification: Confirm that the new simplified builder pattern still produces functionally equivalent W3ID instances and that no critical initialization steps are missing.
  • Public API contract: Although the method signature remains the same, verify that callers relying on password-based seed management are not broken by the removal of that functionality.
  • Type-only imports: Validate that type-only imports for Driver and W3ID don't introduce runtime type-checking issues or unexpected behavior.
  • Test coverage: Ensure existing tests are updated to reflect the new initialization pattern and that no edge cases around seed/key management are left untested.

Poem

🐰 The secrets fade, the keys take flight,
Simpler paths now shine so bright,
No seeds to store, no signers here,
Just builders crafting without fear,
*Hop, hop* — less code, more clear! 🌿

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: remove secrets from evault core' directly describes the main change: removing secrets dependency/logic from the evault core module, which matches the file changes and objectives.
Description check ✅ Passed The description follows the template with all required sections completed (change description, issue number, type of change, testing details, and checklist), though some sections are minimal.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch hotfix/remove-secrets-dep

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ananyayaya129 ananyayaya129 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@coodos coodos left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@coodos
coodos merged commit e4d2d47 into main Nov 12, 2025
4 of 5 checks passed
@coodos
coodos deleted the hotfix/remove-secrets-dep branch November 12, 2025 15:57

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
infrastructure/evault-core/src/core/w3id/w3id.ts (1)

10-14: Remove the unused password parameter.

The password parameter is accepted but never used in the method body. This is misleading to API consumers who might pass a password expecting it to secure their W3ID instance.

Either remove the parameter entirely or document it as deprecated if backward compatibility is required.

Apply this diff to remove the unused parameter:

 static async get(options?: {
     id: string;
     driver: Driver;
-    password?: string;
 }) {
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1afe97f and 73d4e11.

📒 Files selected for processing (1)
  • infrastructure/evault-core/src/core/w3id/w3id.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-04-16T18:04:28.983Z
Learnt from: coodos
Repo: MetaState-Prototype-Project/prototype PR: 99
File: infrastructure/w3id/tests/w3id.test.ts:48-57
Timestamp: 2025-04-16T18:04:28.983Z
Learning: In test files, suggestions to add defensive coding patterns (like extra null checks) are often unnecessary, as tests are designed to fail explicitly when expectations aren't met. The test in `infrastructure/w3id/tests/w3id.test.ts` validates that `id.logs` is an instance of `IDLogManager` before accessing its repository property.

Applied to files:

  • infrastructure/evault-core/src/core/w3id/w3id.ts
🧬 Code graph analysis (1)
infrastructure/evault-core/src/core/w3id/w3id.ts (2)
infrastructure/evault-core/src/core/w3id/log-service.ts (1)
  • LogService (8-42)
infrastructure/w3id/src/w3id.ts (1)
  • W3IDBuilder (32-158)
🔇 Additional comments (2)
infrastructure/evault-core/src/core/w3id/w3id.ts (2)

1-2: LGTM: Type-only imports improve tree-shaking.

The type-only imports for Driver and W3ID are appropriate since they're only used for type annotations, reducing the runtime bundle size.


8-8: LGTM: Constructor simplified appropriately.

The simplified private constructor is appropriate for the singleton pattern.

Comment on lines 21 to +27
const repository = new LogService(options.driver);
const keyId = `w3id-${options.id}`;

try {
// Try to get existing seed
const { seed, nextKeyHash } = await W3ID.secretsStore.getSeed(keyId);
const keyPair = nacl.sign.keyPair.fromSeed(seed);
W3ID.instance = await new W3IDBuilder()
.withId(options.id)
.withRepository(repository)
.withGlobal(true)
.withSigner(createSigner(keyPair))
.withNextKeyHash(nextKeyHash)
.build();
} catch {
// If no seed exists, create new one
const keyPair = nacl.sign.keyPair();
const nextKeyPair = nacl.sign.keyPair();
const nextKeyHash = await hash(uint8ArrayToHex(nextKeyPair.publicKey));

// Store the seed
await W3ID.secretsStore.storeSeed(keyId, keyPair.secretKey, nextKeyHash);

W3ID.instance = await new W3IDBuilder()
.withId(options.id)
.withRepository(repository)
.withSigner(createSigner(keyPair))
.withNextKeyHash(nextKeyHash)
.build();
}
W3ID.instance = await new W3IDBuilder()
.withId(options.id)
.withRepository(repository)
.withGlobal(true)
.build();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Remove unused repository or add signer.

The LogService repository is created and passed to the builder, but according to the W3IDBuilder.build() logic (see relevant code snippets), when no signer is provided, it returns new W3ID(id) and completely ignores the repository.

This means:

  1. The Neo4j storage is unnecessarily initialized
  2. The code is misleading, suggesting log functionality exists when it doesn't
  3. Resources are wasted

Either remove the repository creation entirely, or this indicates incomplete refactoring where the signer should still be provided.

Apply this diff if logs functionality is truly no longer needed:

-const repository = new LogService(options.driver);
-
 W3ID.instance = await new W3IDBuilder()
     .withId(options.id)
-    .withRepository(repository)
     .withGlobal(true)
     .build();

Run the following script to verify if any callers expect the W3ID instance to have logs functionality:


🏁 Script executed:

#!/bin/bash
# Description: Check if any code attempts to access logs or signing functionality on W3ID instances

# Search for access to logs property or signing methods on W3ID instances
rg -n --type=ts -C3 '\bW3ID\b.*\.(logs|sign|verify|signer)' 

# Search for IDLogManager usage that might depend on W3ID logs
rg -n --type=ts -C3 'IDLogManager'

# Check for any tests that verify signing/logging behavior
rg -n --type=ts -C3 'W3ID.*log|W3ID.*sign' -g '*test*' -g '*spec*'

Length of output: 8651



---

🏁 Script executed:

```shell
#!/bin/bash
# Find the exact file referenced in the review
fd -type f -name "w3id.ts" | grep -E "(evault-core|w3id)" | head -20

# Also search for files containing LogService
rg -l "LogService" --type=ts | head -10

Length of output: 315



---

🏁 Script executed:

```shell
#!/bin/bash
# View the specific file and lines mentioned in the review
echo "=== File: infrastructure/evault-core/src/core/w3id/w3id.ts ==="
cat infrastructure/evault-core/src/core/w3id/w3id.ts

echo ""
echo "=== Also check log-service.ts ==="
cat infrastructure/evault-core/src/core/w3id/log-service.ts

Length of output: 1909



---

🏁 Script executed:

```shell
#!/bin/bash
# Find package.json for evault-core
echo "=== package.json in evault-core ==="
cat infrastructure/evault-core/package.json | grep -A 50 '"dependencies"'

# Check if w3id is a local package reference
echo ""
echo "=== Check workspaces or monorepo setup ==="
cat package.json 2>/dev/null | head -40

Length of output: 2859


Remove unused repository creation.

The LogService repository is created and passed to W3IDBuilder, but since no signer is provided, the builder's build() method returns new W3ID(id) without the logs parameter. This means the repository is never used.

From infrastructure/w3id/src/w3id.ts (the actual W3IDBuilder implementation in this monorepo), when no signer is provided, the builder ignores the repository entirely. The code wastefully initializes Neo4j storage that will never be accessed.

Remove the unused repository creation:

-const repository = new LogService(options.driver);
-
 W3ID.instance = await new W3IDBuilder()
     .withId(options.id)
-    .withRepository(repository)
     .withGlobal(true)
     .build();

If logging functionality is needed, add .withSigner() to the builder chain.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const repository = new LogService(options.driver);
const keyId = `w3id-${options.id}`;
try {
// Try to get existing seed
const { seed, nextKeyHash } = await W3ID.secretsStore.getSeed(keyId);
const keyPair = nacl.sign.keyPair.fromSeed(seed);
W3ID.instance = await new W3IDBuilder()
.withId(options.id)
.withRepository(repository)
.withGlobal(true)
.withSigner(createSigner(keyPair))
.withNextKeyHash(nextKeyHash)
.build();
} catch {
// If no seed exists, create new one
const keyPair = nacl.sign.keyPair();
const nextKeyPair = nacl.sign.keyPair();
const nextKeyHash = await hash(uint8ArrayToHex(nextKeyPair.publicKey));
// Store the seed
await W3ID.secretsStore.storeSeed(keyId, keyPair.secretKey, nextKeyHash);
W3ID.instance = await new W3IDBuilder()
.withId(options.id)
.withRepository(repository)
.withSigner(createSigner(keyPair))
.withNextKeyHash(nextKeyHash)
.build();
}
W3ID.instance = await new W3IDBuilder()
.withId(options.id)
.withRepository(repository)
.withGlobal(true)
.build();
W3ID.instance = await new W3IDBuilder()
.withId(options.id)
.withGlobal(true)
.build();
🤖 Prompt for AI Agents
in infrastructure/evault-core/src/core/w3id/w3id.ts around lines 21 to 27, the
code instantiates LogService and passes it to W3IDBuilder but the builder
returns a plain W3ID when no signer is provided so the repository is never used;
remove the unused repository creation and the .withRepository(...) call (and any
related unused imports), or if you actually need logging functionality, supply a
signer by adding .withSigner(...) to the builder chain so the repository will be
consumed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants